#include "OverState.h"
#include "TextureManager.h"
#include "Game.h"
#include <string>
#include <iostream>
#include "Sprite.h"

const string OverState::m_overID = "Over";

OverState::OverState()
{
	// do nothing for now
}

OverState::~OverState()
{
	// do nothing for now
}

void OverState::update()
{
	m_overObject->update();
}

void OverState::render()
{
	m_overObject->draw();
}

bool OverState::init()
{
	/*if (!TheTextureManager::Instance()->load("Menustate.jpg", "board", TheGame::Instance()->getRenderer()))
	{
		return false;
	}
	if (!TheTextureManager::Instance()->load("menu.png", "over", TheGame::Instance()->getRenderer()))
	{
		return false;
	}
	if (!TheTextureManager::Instance()->load("test.png", "test", TheGame::Instance()->getRenderer()))
	{
		return false;
	}*/
	m_sprite_over_state.loadFile("button.txt");

	/*m_board[0] = new GameObject();
	m_board[1] = new GameObject();

	m_board[1]->load(10, 10, 300, 100, 20, "test");
	m_board[0]->load(0, 0, 800, 480, 20, "board");*/

	MenuButton* buttonGotoMenu = new MenuButton(goToMenuGame, m_sprite_over_state, 0, TheGame::Instance()->getRenderer());
	m_overObject = buttonGotoMenu;
	
	//overObject->load(10, 100, 50, 50, 20, "over");

	std::cout << "over state start" << std::endl;

	return true;
}

bool OverState::exit()
{
	TheTextureManager::Instance()->clearFromTextureMap("over");
	TheTextureManager::Instance()->clearFromTextureMap("overtest");
	TheTextureManager::Instance()->clearFromTextureMap("board");

	std::cout << "Exit over state." << endl;

	return true;
}

void OverState::goToMenuGame()
{
	std::cout << "Mwnu state click" << endl;
	TheGame::Instance()->getStateMachine()->changeState(new MenuState());
}


string OverState::getStateID() const
{
	return m_overID;
}